#pragma once

#include "../DefinesCore.hpp"
#include "cybertron/core/SimOneEnv.hpp"
#include "cybertron/core/ComputerEnv.hpp"
#include <iostream>




CYBERTRON_BEGIN

#define DECLARE_APP_INSTANCE(AppClass) AppClass app;
#define GET_APP_INSTANCE(AppClass) ((AppClass*)cybertron::BaseApp::Instance())

    struct SimOneAppInfo
    {
        SimOneAppInfo() {
            mAppId = "";
            mAppType = "";
            mAppName = "";
            mDescription = "";
            mTag = "";
        }
        std::string mAppId;
        std::string mAppType;
        std::string mAppName;
        std::string mDescription;
        std::string mTag;
        //std::string mGroupId;
    };


    class BaseApp : public std::enable_shared_from_this<BaseApp>
    {
    public:
        static BaseApp* Instance(){
            return mInstance;
        }
        BaseApp();
        ~BaseApp();
        CybertronCoreAPI SimOneAppInfo& getAppInfo() { return mAppInfo; }
        //CybertronCoreAPI TaskRunnerPoolClient* getNodeSONClient() { return &mNodeSONClient; }

        CybertronCoreAPI bool init(/*SimOneAppInfo* pAppInfo,*/ int argc, char* argv[]);
        CybertronCoreAPI bool create();

        CybertronCoreAPI std::string getVersionOnCore(const std::string& moduleName, const std::string& version);
        CybertronCoreAPI std::string getVersionOnDependence(const std::string& moduleName, const std::string& version, const std::string& dependenceJson);
        //CybertronCoreAPI std::string getOSConf() { return mOSConfId; };

    protected:
        CybertronCoreAPI virtual void getVerion() { };
        CybertronCoreAPI virtual int parseArguments(int argc, char* argv[]);
        CybertronCoreAPI virtual int beforeRun() { return 0; }
        CybertronCoreAPI virtual int run() { return 0; }


    protected:
        static BaseApp* mInstance;

    protected:

        SimOneEnv::SimOneConfigCenterInfo mSimOneConfigCenterInfo;
        SimOneEnv::SimOneCloudEnvInfo mSimOneCloudEnvInfo;
        /*ComputerEnv::CpuEnvInfo mCpuEnvInfo;
        ComputerEnv::MemoryEnvInfo mMemoryEnvInfo;
        ComputerEnv::DeviceIPInfos mDeviceIPInfos;
        ComputerEnv::DiskInfos mDiskInfos;*/
        SimOneAppInfo mAppInfo;

        //TaskRunnerPoolClient mNodeSONClient;

        //std::string mOSConfId;
    };

    CYBERTRON_END
